#ifndef QTMQTT_H
#define QTMQTT_H

#include <QObject>
#include <QtNetwork>
#include <QNetworkConfigurationManager>
#include <QHostInfo>
#include <qmqtt.h>

using namespace QMQTT;
class QtMqtt : public QObject
{
    Q_OBJECT
public:
    explicit QtMqtt(QObject *parent = nullptr);

protected:
    QMQTT::Client *mqttClient = nullptr;

private:
    QString MqttHost;
    QString MqttPort;
    QString MqttUserName;
    QString MqttPassword;
    QString MqttServerTopic;
    QString MqttProcessTopic;
    QString MqttClientTopic;
    QString MqttAppCloudTopic;
    int itReturnResponse = -1;

    void fnConnectToHost(bool);
    void fnDisconnectToHost();
    void fnMqttSubscribe(QString, int);
    void fnExecuFunction(QStringList);

public slots:
    Q_INVOKABLE void fnMqttConnectStart();
    Q_INVOKABLE void fnSendMqttMessage(QString optParameter);
    Q_INVOKABLE void fnMqttClosed();

private slots:
    void onMqttConnected();
    void onMqttSubscribed(const QString &, const quint8);
    void onMqttReceived(const QMQTT::Message&);
    void onMqttUnsubscribed(const QString&);

signals:
};

#endif // QTMQTT_H
